import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import "bootstrap/dist/js/bootstrap.bundle";
import "element-plus/dist/index.css";
import "font-awesome/css/font-awesome.min.css";
import "bootstrap/dist/css/bootstrap.min.css";
import { directive } from "vue3-menus";
import _lodash from "lodash";
import theia from "theia-js";
import utils from "./utils";

// 定义 install 方法，接收 Vue 作为参数。如果使用 use 注册插件，则所有的组件都将被注册
const install = function (app) {
  // 判断是否安装
  if (install.installed) return;

  // 遍历注册全局组件
  app.use(ElementPlus, { size: "small", zIndex: 3000 });
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
  }
  let ftheia = theia.load();
  app.config.globalProperties.$theia = ftheia;
  app.config.globalProperties.$_ = _lodash;
  app.config.globalProperties.$utils = utils;
  app.directive("menus", directive);
  window._ = _lodash;
  window.$utils = utils;
  window.$theia = ftheia;
};
if (typeof window !== "undefined" && window.Vue) {
  install(window.Vue);
}
export default {
  install,
};
